#ifndef MEMORY_TOOLS_H_
#define MEMORY_TOOLS_H_

#include <Common/GlobalDefines.h>
#include <Eigen/Dense>

GLOBAL_NAMESPACE_BEGIN

namespace MemoryTools
{
    static void copyMemery(const Eigen::MatrixXd& data, double* dest)
    {
        // NOTE: the output dest is row-major!!!
        int nDim = data.cols();
        int nSize = data.rows();
        for (int x = 0; x < nSize; x++)
        {
            int offset = x*nDim;
            for (int y = 0; y < nDim; y++)
            {
                dest[y + offset] = data(x, y);
            }
        }
    }

    static void copyMemery(const Eigen::VectorXd& vec, double* dest)
    {
        // NOTE: the output dest is row-major!!!
        int nDim = vec.rows();
        int nSize = 1;
        for (int i = 0; i < nDim; i++)
        {
            dest[i] = vec(i);
        }
    }

}

GLOBAL_NAMESPACE_END

#endif//MEMORY_TOOLS_H_
